ISCModelObjectCollection Interface

The following table contains information on the ISCModelObjectCollection interface, which is used when you create a new model object:

Signature

Description

Valid Arguments

ISCModelObjectCollection * Collect(VARIANT Root, VARIANT ClassId [optional], VARIANT Depth [optional], VARIANT MustBeOn [optional], VARIANT MustBeOff[optional])

Creates a Model Objects collection, which represents a subcollection of itself

Root:

  • VT_UNKNOWN � The ISCModelObject pointer of the root object. Returns the descendants of the given object.
  • VT_BSTR � The ID of the root object. Returns the descendants of the object with the given object identifier.

ClassId:

  • Empty � Not needed when obtaining the children of an object.

Depth:

  • VT_I4 � Set depth to 1 when obtaining the immediate children of an object.

MustBeOn:

  • Empty � Not needed when obtaining the children of an object.

MustBeOff:

  • Empty � Not needed when obtaining the children of an object.

ISCModelObject * Add(VARIANT Class, VARIANT ObjectId [optional])

Adds an object of type Class to the model

Class:

  • VT_BSTR � Name of a class. Creates an object of the given class name.
  • VT_BSTR � Class ID of an object type. Creates an object of the class with the given identifier.

ObjectId:

  • Empty � The API assigns an object identifier for a new object.
  • VT_BSTR � ID for a new object. The API assigns the given object identifier to the new object.

Example 20

The following example illustrates how to create objects using C++. The example uses a Session object from Example 6:

ISCSession::BeginTransaction() must be called prior to calling this function

// ISCSession::CommitTransaction() must be called upon returning from this // function void CreateObject(ISCSessionPtr & scSessionPtr, CString & csType, ISCModelObjectPtr & parentObj) { variant_t transactionId; // transaction ID for the session VariantInit(&transactionId); transactionId = scSessionPtr->BeginTransaction(); ISCModelObjectCollectionPtr childObjColPtr = scSessionPtr->GetModelObject()->Collect(parentObj->GetObjectId(),vtMissing,(long)1); // get // child objects // Add child object to collection ISCModelObjectPtr childObjPtr = childObjColPtr->Add(COleVariant(csType)); // … scSessionPtr->CommitTransaction(transactionId); }

The following example illustrates how to create objects using Visual Basic .NET. The example uses a Session object from Example 6:

Public Sub AddNewObject(ByRef scSession As SCAPI.Session, _
             ByRef parentObj As SCAPI.ModelObject, type As String)
    Dim scObj as SCAPI.ModelObject
    Dim scChildObjCol As SCAPI.ModelObjects
    Dim transactionID as Variant
    
    transactionID = scSession.BeginTransaction
    scChildObjCol = scSession.ModelObjects.Collect(parentObj, , 1)   ' child objects collection
    scObj = scChildObjCol.Add(type)    ' add new object to the child object collection
     
    scSession.CommitTransaction( transactionID )
End Sub